import Vue from "vue"
import Router from "vue-router"

Vue.use(Router)

import Layout from "@/layout"

export const constantRoutes = [
  {
    path: "/login",
    component: () => import("@/views/login/index"),
    hidden: true
  },
  {
    path: "/404",
    component: () => import("@/views/404"),
    hidden: true
  },
  // {
  //   path: "/",
  //   component: Layout,
  //   redirect: "/chart",
  //   children: [
  //     {
  //       path: "chart",
  //       name: "Chart",
  //       component: () => import("@/views/chart/index"),
  //       meta: { title: "平台概览", icon: "dashboard" }
  //     }
  //   ]
  // },
  {
    path: "/",
    component: Layout,
    redirect: "/chart",
    children: [
      {
        path: "chart",
        name: "Chart",
        component: () => import("@/views/newSystem/projectOverview/index"),
        meta: { title: "项目概览", icon: "dashboard" }
      }
    ]
  },
  {
    path: "/setView",
    component: Layout,
    children: [
      {
        path: "setDetail",
        name: "setDetail",
        component: () => import("@/views/newSystem/settingManagement/projectView/setView")
      }
    ]
  },
  {
    path: "/device",
    component: Layout,
    children: [
      {
        path: "guhuaDetail",
        name: "guhuaDetail",
        component: () => import("@/views/device/guhuaDetail/index")
      }
    ]
  },
  {
    path: "/device",
    component: Layout,
    children: [
      {
        path: "kepeizhiDetail",
        name: "kepeizhiDetail",
        component: () => import("@/views/device/kepeizhiDetail/index")
      }
    ]
  },
  {
    path: "/device",
    component: Layout,
    children: [
      {
        path: "deviceDetail",
        name: "deviceDetail",
        component: () => import("@/views/newSystem/showManage/deviceQuery/deviceDetail/index")
      }
    ]
  },
  {
    path: "/devicesSetting",
    component: Layout,
    children: [
      {
        path: "devicesSettingDetail",
        name: "devicesSettingDetail",
        component: () => import("@/views/newSystem/settingManagement/devicesSetting/detail")
      }
    ]
  },
  {
    path: "/monitoringCenter",
    component: Layout,
    children: [
      {
        path: "monitoringCenterDetail",
        name: "monitoringCenterDetail",
        component: () => import("@/views/newSystem/showManage/monitoringCenter/detail")
      }
    ]
  },
  {
    path: "/protocolMessage",
    component: Layout,
    children: [
      {
        path: "protocolMessageDetail",
        name: "protocolMessageDetail",
        component: () => import("@/views/newSystem/devicesControl/protocolMessage/detail")
      }
    ]
  },
  {
    path: "/protocolMessage",
    component: Layout,
    children: [
      {
        path: "protoMessageDetail",
        name: "protoMessageDetail",
        component: () => import("@/views/newSystem/devicesControl/protocolMessage/protocolMessageDetail")
      }
    ]
  },
  {
    path: "/operationControl",
    component: Layout,
    children: [
      {
        path: "workflowDetails",
        name: "workflowDetails",
        component: () => import("@/views/newSystem/operationControl/workFlow/details/index.vue")
      }
    ]
  },
  {
    path: "/reportStatistics",
    component: Layout,
    children: [
      {
        path: "operationRecordDetail",
        name: "operationRecordDetail",
        component: () => import("@/views/newSystem/reportStatistics/operationRecord/detail.vue")
      }
    ]
  },

  {
    path: "/reportStatistics",
    component: Layout,
    children: [
      {
        path: "deviceFaultRecordDetail",
        name: "deviceFaultRecordDetail",
        component: () => import("@/views/newSystem/reportStatistics/deviceFaultRecord/detail.vue")
      },
    ]
  },
  {
    path: "/reportStatistics",
    component: Layout,
    children: [
      {
        path: "deviceMeasureInfoDetail",
        name: "deviceMeasureInfoDetail",
        component: () => import("@/views/newSystem/reportStatistics/deviceMeasureInfo/detail.vue")
      }
    ]
  },
  {
    path: "/reportStatistics",
    component: Layout,
    children: [
      {
        path: "deviceStatusRecordDetail",
        name: "deviceStatusRecordDetail",
        component: () => import("@/views/newSystem/reportStatistics/deviceStatusRecord/detail.vue")
      }
    ]
  },
  {
    path: "/reportStatistics",
    component: Layout,
    children: [
      {
        path: "devicePlatformOperateRecordDetail",
        name: "devicePlatformOperateRecordDetail",
        component: () => import("@/views/newSystem/reportStatistics/devicePlatformOperateRecord/detail.vue")
      }
    ]
  },
  {
    path: "/chartControl",
    component: Layout,
    children: [
      {
        path: "dispositionVisualization",
        name: "configVisualization",
        component: () => import("@/views/newSystem/chartControl/settingChart/config.vue")
      }
    ]
  },
  {
    path: "/instantiate",
    component: Layout,
    children: [
      {
        path: "instantiateList",
        name: "InstantiateList",
        component: () => import("@/views/newSystem/operationControl/workFlow/instantiate/list.vue")
      }
    ]
  },
  {
    path: "/instantiate",
    component: Layout,
    children: [
      {
        path: "instantiateIndex",
        name: "InstantiateIndex",
        component: () => import("@/views/newSystem/operationControl/workFlow/instantiate/index.vue")
      }
    ]
  },
  {
    path: "/showManage",
    component: Layout,
    children: [
      {
        path: "showManageInstantiate",
        name: "showManageInstantiate",
        component: () => import("@/views/newSystem/showManage/workflow/instantiate/index.vue")
      }
    ]
  },
  {
    path: "/showManage",
    component: Layout,
    children: [
      {
        path: "realTimeLoadDetail",
        name: "realTimeLoadDetail",
        component: () => import("@/views/newSystem/showManage/realTimeLoad/detail.vue")
      }
    ]
  },
  // {
  //   path: "/visControl",
  //   component: Layout,
  //   children: [
  //     {
  //       path: "manualSetUp",
  //       name: "manualSetUp",
  //       component: () => import("@/views/newSystem/showManage/realTimeLoad/details/index.vue")
  //     }
  //   ]
  // },
  {
    path: "/visControl",
    component: Layout,
    children: [
      {
        path: "manualSetUp",
        name: "manualSetUp",
        component: () => import("@/views/newSystem/visControl/initializeVis/details/index.vue")
      }
    ]
  },
  // {
  //   path: "/device",
  //   component: Layout,
  //   children: [
  //     {
  //       path: "kepeizhiDetail",
  //       name: "kepeizhiDetail",
  //       component: () => import("@/views/device/kepeizhiDetail/index")
  //     }
  //   ]
  // }
]

const createRouter = () =>
  new Router({
    scrollBehavior: () => ({ y: 0 }),
    routes: constantRoutes
  })
const router = createRouter()

export function resetRouter () {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher // reset router
}

export default router
